package scfg.utils.trainging_results.delete;
import java.util.*;
import java.io.*;

import scfg.utils.trainging_results.StatsCollector;

public class TrainingResultsParser {

	public static ResultsFile combine(List<ResultsFile> rfList, String filename) {
		PriorityQueue<Run> all = new PriorityQueue<Run>();
		for (ResultsFile rf : rfList) {
			PriorityQueue<Run> temp = rf.getPQ();
			while (!temp.isEmpty())
				all.add(temp.poll());
		}
		return new ResultsFile(new File(filename), all);
	}

	/**
	 * @param args
	 */
//	public static void main(String[] args) {
//		if (args.length >= 0) {
//			List<ResultsFile> rfList = new ArrayList<ResultsFile>();
//			for (int i = 0; i < args.length; i++) {
//				File f = new File(args[i]);
//				if (f.exists() && !f.isDirectory()) {
//					System.out.println("Processing " + f.getAbsolutePath());
//					ResultsFile r = new ResultsFile(f);
//					rfList.add(r);
//					try {
//						BufferedWriter bf = new BufferedWriter(new FileWriter(f
//								.getAbsolutePath().replaceAll("\\.txt",
//										"_sort.txt")));
//						bf.write(r.toString());
//						bf.write("Final Stats Results:\n");
//						bf.write("--------------------\n");
//						bf.write(StatsCollector.testCollection(r));
//						bf.close();
//					} catch (Exception e) {
//						e.printStackTrace();
//					}
//				}
//			}
//			try {
//				File all = new File("all.txt");
//				ResultsFile r = combine(rfList, all.getAbsolutePath());
//				BufferedWriter bf = new BufferedWriter(new FileWriter(all
//						.getAbsolutePath().replaceAll("\\.txt", "_sort.txt")));
//				bf.write(r.toString());
//				bf.write("Final Stats Results:\n");
//				bf.write("--------------------\n");
//				bf.write(StatsCollector.testCollection(r));
//				bf.close();
//			} catch (Exception e) {
//				e.printStackTrace();
//			}
//			System.out.println("Exiting...");
//		}
//	}
}
